﻿#ifndef NPPORT3D_H
#define NPPORT3D_H
/*
* npapi入口
*/
#include "npport3d_global.h"
#include <QWidget>
#include "qtnpapi.h"
#include "qtbrowserplugin.h"

class QStackedWidget;
class ObjectEntities;
class ObjectEntitiesArray;
class IntArray;
class StringArray;
class DoubleArray;
class PositionArray;
class ImplementAPI;

class NPPORT3D_EXPORT npPort3d:public QWidget,public QtNPBindable
{
	Q_OBJECT
		Q_CLASSINFO("ClassID", "{2AC26F09-1A4A-465B-A582-76C6268A8055}")
		Q_CLASSINFO("InterfaceID", "{2df735ba-da4f-4fb7-8f35-b8dfbf8cfd9a}")
		Q_CLASSINFO("EventsID", "{449de213-f8bd-4d2e-a2cf-eab407c03245}")
		Q_CLASSINFO("MIME", "application/x-npport3d-plugin")
public:
	npPort3d(QWidget* parent = 0);
	~npPort3d();
public slots:
	void release();
	bool openMap(const QString& mapname);
	bool closeMap();
	void moveCenterTo(double x,double y);
	void makeObjectColorBlink(const QString& ids,int totaltime,int intterval,int r,int g,int b,int a);
	void stopObjectColorBlink(const QString& ids);
	void makeObjectBlink(const QString& ids,int totaltime,int intterval);
	void stopObjectBlink(const QString& ids);
	void setLookAt(const QString& ids,int offsetxy,int offsetxz,int distance);
	void getLookAt(double& eyex,double& eyey,double& eyez,double& centerx,double& centery,
										double& centerz,double& upx,double& upy,double& upz,double& distance);
	bool followObject_1(const QString& id,double centeroffsetx,double centeroffsety,double centeroffsetz,int distance,int anglexy, int anglexz);
	bool followObject_2(const QString& id,const QString& name);
	void setScanMode(int mode);
	void setScanSpeed(int speed);
	void setToolTip(const QString& text);
	void setToolTipParameter(int textsize,int textr,int textg,int textb,int backgroundr,
		int backgroundg,int backgroundb,int backgrounda);
	void createOrUpdateObjects(ObjectEntitiesArray* entitiesarray);
	void createOrUpdateObjects_2(const QString& objectid,const QString& mmsi,const QString& imo,const QString& type,
		const QString& name,double lng,double lat,double height,const QString& callsign,double beam,const QString& cargotype,
		const QString& country,double course,const QString& dest,double draught,const QString& eta,double heading,
		double lasttime,double left,double length,double rot,double speed,const QString& status,double trail,double time);
	void createOrUpdateObjects_3(const QString& datalist);
	bool createAutoMoveObjectWithTrack(ObjectEntities* entities, PositionArray* p,DoubleArray* t,bool loop);
	bool createAutoUniformMoveObjectWithTrack(ObjectEntities* entities, PositionArray* p,double speed,bool loop);
	bool createAutoUniformMoveObjectWithTrack_1(const QString& id,const QString& type,const QString& name,
		const QString& tracklist,double speed,bool loop);
	bool deleteObject(const QString& id);
	void setPropertyWindowParameter(int windowwidth,int windowheight,double namewidth,double valuewidth,
		int nametextsize,int valuetextsize,int nametextcolorr,int nametextcolorg,int nametextcolorb,int valuetextcolorr
		,int valuetextcolorg,int valuetextcolorb);
	//void updateProfessionProperty(ObjectEntities* entities);
	void showPropertyWidget(ObjectEntities* entities);
	void hidePropertyWidget();
	void addTabsInteractionWindow(const QString& title,int r,int g,int b);
	void removeTabsInteractionWindow(const QString& title);
	void addTextInteractionInformationWindow(const QString& text,const QString& title);
	void setObjectsValidStatus(const QString& ids,const QString& status);
	bool showObject(const QString& id,bool state);
	bool showObjects(StringArray* ids,bool state);
	bool showTarget(int type, int subtype,bool state);
	void setDefaultResourceDir(const QString& dir);
	void setDefaultLogFileDir(const QString& dir);
	void addRemarkedAt(const QString& remarklayername,const QString& text,double x,double y,double z);
	void removeRemark(const QString& remarklayername,const QString& text);
	void showRemarkLayer(const QString& remarkname);
	void hideRemarkLayer(const QString& remarkname);
	void showArea(const QString& areaname);
	void hideArea(const QString& areaname);
	void addToolBarButton(int buttonType);
	void addAdvancedToolBarButton(int type,const QString& buttonname,const QString& buttonicon,const QString& buttoniconeffect);
	void setToolBarActive(int type,bool active);
	QString getAllPlayCameraAnimationName();
	void playCameraAnimation(const QString& name);
	void showGuideMapWindow();
	void hideGuideMapWindow();

	void createOrUpdateAccidentAt(const QString& id,int type,double x,double y);
	void playHudVideo(const QString& filename);
	void stopPlayHudVideo();
	void setPathTrajectory(const QString& id,const QString& controlposition);
	void showPathTrajectory(const QString& id,bool show);
	void setDestination(double x,double y,double z,const QString& filename);
	void showDestination(const QString& id,int distance);
	void hideDestination(const QString& id);
private:
	void writeLog(const QString& log1,const QString& log2,int priority);
	void resetTime(const QString& title);
	void writeTimeLog(const QString& title);
	void loadLanguagePlugin();
	void initialUI();
	bool												_logOrNot;
	ImplementAPI*									_implementActivex;
	QStackedWidget*										_mainWidget;
	QString												_currentMapFullName;
private slots:
	void slotsHoverEvent(const int,const int,const double,const double,QString mess);
	void slotsBreakHoverEvent();
	void slotsMouseLeftClickEvent(const int,const int,const double,const double,QString mess);
	void slotsMouseRightClickEvent(const int,const int,const double,const double,QString mess);
	void slotsMouseDoubleClickEvent(const int,const int,const double,const double,QString mess);
	void slotsKeyPressEvent(const int,const int,const int,const double,const double);
	void slotsToolButtonClick(QString name);
signals:
	void hoverEvent(const int,const int,const double,const double,QString mess);
	void breakHoverEvent();
	void mouseLeftClickEvent(const int,const int,const double,const double,QString mess);
	void mouseRightClickEvent(const int,const int,const double,const double,QString mess);
	void mouseDoubleClickEvent(const int,const int,const double,const double,QString mess);
	void keyPressEvent(const int,const int,const int,const int,const double,const double);
	void toolButtonClickEvent(QString buttonname);
};
#endif // NPPORT3D_H